package GraphTheory;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

class Node
{	public int x,y;
	public Node(int X,int Y)
	{	x=X;y=Y;
	}
}
class Solver1033
{	int n;
	int[][] State;//-1:block; 0:not visited; 1:visited;
	
	public void Input()
	{	Scanner in=new Scanner(System.in);
		String tmp;
		
		n=in.nextInt();in.nextLine();
		State=new int[n+2][n+2];
		Arrays.fill(State[0],-1);Arrays.fill(State[n+1],-1);
		for (int i=1;i<=n;i++)
		{	tmp=in.nextLine();
			State[i][0]=-1;State[i][n+1]=-1;
			for (int j=0;j<tmp.length();j++)
				State[i][j+1]=((tmp.charAt(j)=='.')?0:-1);
		}
	}
	private int FloodVisit(int x,int y)
	{	int accu=0;
		int[] Dx={-1,1,0,0},Dy={0,0,1,-1};
		Queue<Node> Focus=new LinkedList<Node>();
		Focus.add(new Node(x,y));State[x][y]=1;
		while (!Focus.isEmpty())
		{	Node f=Focus.remove();
			for (int i=0;i<=3;i++)
			{	int nx=f.x+Dx[i],ny=f.y+Dy[i];
				if (State[nx][ny]==-1) accu+=9;
				else if (State[nx][ny]==0)
				{	Focus.add(new Node(nx,ny));State[nx][ny]=1;
				}
			}
		}
		return accu;
	}
	public void Solve()
	{	Input();
		int rs=0;
		rs+=FloodVisit(1,1);
		if (State[n][n]==0) rs+=FloodVisit(n,n);
		rs-=36;
		System.out.println(rs);
	}
}
public class P1033
{	public static void main(String[] args)
	{	Solver1033 solver=new Solver1033();
		solver.Solve();
	}
}
